package br.com.venda.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.com.pessoa.Pessoa;
import br.com.venda.ItemVenda;

public class IniciarVenda extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public IniciarVenda() {
        // TODO Auto-generated constructor stub
    }
    
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	doPost(request,response);
    }
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession sessao = request.getSession();
		ArrayList<ItemVenda> itensVenda = new ArrayList<ItemVenda>();
		Pessoa cliente = null;
		
		sessao.setAttribute("cliente", cliente );
		sessao.setAttribute("itensvenda", itensVenda);
		
		
		
		Pessoa p = (Pessoa) sessao.getAttribute("funcionario");
		request.setAttribute("funcionario.nome", p.getNome());
		
		String nextJSP = "/vendaPrincipal.jsp";
		
		RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
		
		dispatcher.forward(request,response);
	}
}